﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace TwitterBobby
{
    [ServiceContract]
    public interface ITwitterBobbyService
    {
        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/GetAllChannels")]
        IEnumerable<ChannelDTO> GetAllChannels();

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/GetMessagesByChannelName/{channelName}")]
        IEnumerable<MessageDTO> GetMessagesBYChannelName(string channelName);

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/CreateChannel/{channelName}")]
        void CreateChannel(string channelName);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/Post",
            BodyStyle = WebMessageBodyStyle.WrappedRequest,
            RequestFormat = WebMessageFormat.Json,
            ResponseFormat = WebMessageFormat.Json)]
        void PostMessage(MessageToPOST msg);
    }

    [DataContract]
    public class MessageToPOST
    {
        [DataMember]
        public string MsgText
        {
            get { return MsgText; }
            set { MsgText = value; }
        }

        [DataMember]
        public DateTime MsgDate
        {
            get { return MsgDate; }
            set { MsgDate = value; }
        }

        [DataMember]
        public string MsgChannel
        {
            get { return MsgChannel; }
            set { MsgChannel = value; }
        }
    }
}
